package com.cw1.factory.simpleFactory.pizzastore.order;

import com.cw1.factory.simpleFactory.pizzastore.factroy.SimpleFactory;
import com.cw1.factory.simpleFactory.pizzastore.pizza.Pizza;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * @Author qiuMi
 * @description 披萨 - 订单 方式二
 * @Date 2022-10-05 16:38
 **/
public class OrderPizza2 {

    Pizza pizza = null;
    String orderType = "";

    public OrderPizza2() {
        do {
            orderType = getType();
            pizza = SimpleFactory.createPizza2(orderType);
            if (pizza != null){
                // 写出pizza制作过程
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            }else {
                System.out.println("订购披萨失败");
                break;
            }

        } while (true);
    }

    /**
     * 写个方法 - 获取客户希望订购的披萨
     *
     * @return 披萨 - 类型
     */
    private String getType() {
        try {
            System.out.println("input pizza 的种类");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            // 逐行读取披萨的种类
            String orderType = bufferedReader.readLine();
            return orderType;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }

    }
}
